 package io.gitee.falllee.dao.generator;

import java.util.Iterator;

import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.codegen.mybatis3.IntrospectedTableMyBatis3Impl;
import org.springframework.util.CollectionUtils;

/**
 * @author batty
 * @date 2019/08/09
 */
public class IntrospectedTableImpl extends IntrospectedTableMyBatis3Impl {
    
    @Override
    public void addPrimaryKeyColumn(String columnName) {
        // 主键仅添加第一个
        if (!CollectionUtils.isEmpty(primaryKeyColumns)){
            return;
        }
        Iterator<IntrospectedColumn> iter = baseColumns.iterator();
        while (iter.hasNext()) {
            IntrospectedColumn introspectedColumn = iter.next();
            if (introspectedColumn.getActualColumnName().equals(columnName)) {
                primaryKeyColumns.add(introspectedColumn);
                iter.remove();
                break;
            }
        }

    }
}
